<?php
/**
 * Created by PhpStorm.
 * User: hui
 * Date: 2017/2/26
 * Time: 18:59
 */
namespace app\admin\controller;

use think\Loader;

class Module extends Base
{
    public function index()
    {
        $list = Loader::model('module','logic')->getModule();
        $title = '菜单与权限';
        $this->assign('list',$list);
        $this->assign('title',$title);
        return $this->fetch();
    }

    public function edit()
    {
        $obj = Loader::model('module','logic');
        if ($this->request->isPost()){
            $res = $obj->setModule();
            if (is_int($res)){
                $this->success('菜单更新成功');
            }else{
                $this->error();
            }
        }
        $id = input('module_id');
        $module = $obj->getModule($id);
        $menu = $obj->getMenu();
        $this->assign('menu',$menu);
        $this->assign('module',$module);
        return $this->fetch();
    }
}